﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace PingTest
{
    class Config
    {
        public static int THRESHOLD_DISCONNECT_LOST_RATE = 30;
        public static int THRESHOLD_DISCONNECT_BUFFER_SIZE = 128;
        
        public static int THRESHOLD_GOOD_LOST_RATE = 3;
        public static int THRESHOLD_GOOD_BUFFER_SIZE = 512;
        public static int THRESHOLD_GOOD_LATENCY = 70;

        public static int THRESHOLD_BAD_LOST_RATE = 5;
        public static int THRESHOLD_BAD_BUFFER_SIZE = 64;
        public static int THRESHOLD_BAD_LATENCY = 150;
        //
        public static string MAIN_FORM_TITLE = "Advanced Ping Test v2.0beta";
        public static Color COLOR_GOOD = Color.Green;
        public static Color COLOR_BAD = Color.Orange;
        public static Color COLOR_OTHER = Color.YellowGreen;

        //
        public static int INITIAL_BUFFER_SIZE = 128;
        public static int MIN_BUFFER_SIZE = 32;
        public static int MAX_BUFFER_SIZE = 8192;

        public static int PING_INTERVAL = 500;
        public static int PING_TIME_OUT = 444;
        public static int PING_QUEUE_LONG_SIZE = 200;
        public static int PING_QUEUE_SHORT_SIZE = 20;

        public static byte[] PING_BUFFER_16 = new byte[16];
        public static byte[] PING_BUFFER_32 = new byte[32];
        public static byte[] PING_BUFFER_64 = new byte[64];
        public static byte[] PING_BUFFER_128 = new byte[128];
        public static byte[] PING_BUFFER_256 = new byte[256];
        public static byte[] PING_BUFFER_512 = new byte[512];
        public static byte[] PING_BUFFER_1024 = new byte[1024];
        public static byte[] PING_BUFFER_2048 = new byte[2048];
        public static byte[] PING_BUFFER_4096 = new byte[4096];
        public static byte[] PING_BUFFER_8192 = new byte[8192];

        public static byte[] GetBuffer(int size)
        {
            switch (size)
            {
                case 16:
                    return PING_BUFFER_16;                    
                case 32:
                    return PING_BUFFER_32;                    
                case 64:
                    return PING_BUFFER_64;                   
                case 128:
                    return PING_BUFFER_128;                    
                case 256:
                    return PING_BUFFER_256;                    
                case 512:
                    return PING_BUFFER_512;                    
                case 1024:
                    return PING_BUFFER_1024;                    
                case 2048:
                    return PING_BUFFER_2048;
                case 4096:
                    return PING_BUFFER_4096;
                case 8192:
                    return PING_BUFFER_8192;
                default :
                    return new byte[size];
            }
        }
    }
}
